package oop2;

import java.util.Arrays;

/**
 * @author oldliu
 * @since 1.0
 */
//班级
public class JadeClass {
    String name;
    String dirTeacher;
    String techTeacher;
    String stus[] = new String[30];
    int count = 0;//当前班级人数

    //加人，减人，输出信息，找人
    public void show() {
        System.out.println("这是" + name);
        System.out.println("指导老师" + dirTeacher + ",教学老师" + techTeacher);
        System.out.println("学生信息如下：");
        System.out.println("当前人数" + count + "人");
        for (int i = 0; i < count; i++) {
            System.out.print(stus[i] + " ");
        }
        System.out.println();
    }

    //新生加入班级
    public boolean add(String s) {
        if (count >= stus.length) {
            System.out.println("扩容一次");
            //扩容，保留原来的值
            stus = Arrays.copyOf(stus, stus.length + 16);
            //return false;//人满
        }
        stus[count++] = s;
        return true;
    }

    //找人
    public boolean find(String name) {
        for (int i = 0; i < count; i++) {
            if (stus[i].equals(name)) {
                return true;
            }
        }
        return false;
    }

    //在一个范围内查找学生姓名
    public boolean search(int start, int end, String name) {
        for (int i = start; i >= 0 && i < end && end < count; i++) {
//            if (stus[i] == null) {
//                return false;
//            }鸡肋
            if (stus[i].equals(name)) {
                return true;//在
            }
        }
        return false;//不在
    }

    //删除学生
    public boolean fire(String name) {

        return false;
    }
}
